#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from typing import Optional, List
from datetime import datetime
from pydantic import BaseModel, Field


class ProjectCreate(BaseModel):
    """
    创建项目入参
    """
    project_number: str = Field(..., description="项目号")
    project_type: str = Field(..., description="项目类型")
    funding_amount: float = Field(..., description="资助金额")
    start_date: datetime = Field(..., description="开始时间")
    end_date: datetime = Field(..., description="结束时间")
    status: str = Field(..., description="当前状态")


class ProjectUpdate(BaseModel):
    """
    更新项目入参
    """
    id: str = Field(..., description="项目ID")
    project_number: Optional[str] = Field(None, description="项目号")
    project_type: Optional[str] = Field(None, description="项目类型")
    funding_amount: Optional[float] = Field(None, description="资助金额")
    start_date: Optional[datetime] = Field(None, description="开始时间")
    end_date: Optional[datetime] = Field(None, description="结束时间")
    status: Optional[str] = Field(None, description="当前状态")


class ProjectDetail(BaseModel):
    """
    项目详情
    """
    id: str = Field(..., description="项目ID")
    project_number: str = Field(..., description="项目号")
    project_type: str = Field(..., description="项目类型")
    funding_amount: float = Field(..., description="资助金额")
    start_date: datetime = Field(..., description="开始时间")
    end_date: datetime = Field(..., description="结束时间")
    status: str = Field(..., description="当前状态")
    created_at: datetime = Field(..., description="创建时间")
    updated_at: datetime = Field(..., description="更新时间")

    model_config = {"from_attributes": True}


class ProjectListResponse(BaseModel):
    """
    项目列表出参
    """
    record_total: int = Field(default=0, description="总量")
    record_list: List[ProjectDetail] = Field(default=[])


class ProjectIdRequest(BaseModel):
    """
    项目ID请求参数
    """
    id: str = Field(..., description="项目ID")